home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_02_08
/
2n08023a
< prev
next >
Wrap
Text File
|
1991-06-29
|
821b
|
35 lines
'Listing 2 - EXIST.BAS
'Checks for existence of a file.
DEFINT A-Z
'$INCLUDE: 'qb.bi'
DECLARE FUNCTION Exist (FileSpec$)
INPUT "Enter desired file spec: ", FileSpec$
IF Exist(FileSpec$) THEN
PRINT FileSpec$ + " exists."
ELSE
PRINT FileSpec$ + " not found."
END IF
END
FUNCTION Exist (FileSpec$)
DIM Regs AS RegTypeX
Temp$ = FileSpec$ + CHR$(0)
Regs.ax = &H4E00 'Find first matching file
Regs.cx = 0
Regs.ds = VARSEG(Temp$)
Regs.dx = SADD(Temp$)
CALL InterruptX(&H21, Regs, Regs)
IF Regs.ax AND 255 THEN
Exist = 0
ELSE
Exist = -1
END IF
END FUNCTION